'use strict'; document.write('
'); var DMN = DMN || {}; DMN.baseUrl = 'https://www.designmynight.com'; DMN.partnersUrl = 'https://partners.designmynight.com'; DMN.ticketsUrl = 'https://tickets.designmynight.com'; DMN.formConfig = DMN.formConfig || {}; DMN.formConfig[5567409] = {"type":"tonic","eventIds":["557efc0e0c23ef3e3f8b4577"],"format":"card","stage":false,"showContent":false,"params":"?event_id=557efc0e0c23ef3e3f8b4577&r=5567409&key=54eee0a10df6908d07f28dab&format=card&title=Buy+a+Ticket","title":"Buy a Ticket","logo":"\/\/static.designmynight.com\/images\/design-my-night.png"}; 'use strict'; // Polyfill for String.trim() ''.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,'')}) // Polyfill for indexOf() if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(elt /*, from*/) { var len = this.length >>> 0; var from = Number(arguments[1]) || 0; from = (from < 0) ? Math.ceil(from) : Math.floor(from); if (from < 0) from += len; for (; from < len; from++) { if (from in this && this[from] === elt) return from; } return -1; }; } DMN.loadScript = function(url, callback){ var script = document.createElement("script"); script.type = "text/javascript"; if (script.readyState){ //IE script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } } } else { //Others script.onload = function(){ callback(); } } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } DMN.loadCss = function(url){ var fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet") fileref.setAttribute("type", "text/css") fileref.setAttribute("href", url) if (typeof fileref!="undefined") { document.getElementsByTagName("head")[0].appendChild(fileref) } }; DMN.ready = (function () { var ready_event_fired = false; var ready_event_listener = function (fn) { // Create an idempotent version of the 'fn' function var idempotent_fn = function () { if (ready_event_fired) { return; } ready_event_fired = true; return fn(); } // The DOM ready check for Internet Explorer var do_scroll_check = function () { if (ready_event_fired) { return; } // If IE is used, use the trick by Diego Perini // http://javascript.nwbox.com/IEContentLoaded/ try { document.documentElement.doScroll('left'); } catch(e) { setTimeout(do_scroll_check, 1); return; } // Execute any waiting functions return idempotent_fn(); } // If the browser ready event has already occured if (document.readyState === "complete") { return idempotent_fn() } // Mozilla, Opera and webkit nightlies currently support this event if (document.addEventListener) { // Use the handy event callback document.addEventListener("DOMContentLoaded", idempotent_fn, false); // A fallback to window.onload, that will always work window.addEventListener("load", idempotent_fn, false); // If IE event model is used } else if (document.attachEvent) { // ensure firing before onload; maybe late but safe also for iframes document.attachEvent("onreadystatechange", idempotent_fn); // A fallback to window.onload, that will always work window.attachEvent("onload", idempotent_fn); // If IE and not a frame: continually check to see if the document is ready var toplevel = false; try { toplevel = window.frameElement == null; } catch (e) {} if (document.documentElement.doScroll && toplevel) { return do_scroll_check(); } } }; return ready_event_listener; })(); DMN.getFormScope = function(formId){ // Get the first form if none specified if ( !formId ){ var forms = DMN.formConfig; var formId; angular.forEach( forms, function(config, id){ if ( !formId ){ formId = id; } }); } var form = angular.element(document.getElementById('dmn-form-' + formId)); var formScope = form.scope(); return formScope; } DMN.val = function(){ if (!arguments.length){ return false; } if ( !angular.isObject(arguments[0]) ){ arguments[0] = { field: arguments[0], value: arguments[1] }; } var defaults = { formId: false } var options = angular.extend({}, defaults, arguments[0]); // Stop if no input specified if ( !options.field ){ return false; } // Get the form scope var formScope = DMN.getFormScope(options.formId); // Stop if no form scope if ( !formScope ){ return false; } // Return the current value if no value specified if ( typeof options.value === 'undefined' ){ return formScope[options.field]; } // Try to get the type from the name if it's not a known type ID if ( options.field === 'type' && !formScope.currentVenue.booking_types[options.value] ){ var found = false; angular.forEach( formScope.currentVenue.booking_types, function(type){ if ( type.name.trim() == options.value.trim() ){ options.value = type.id; found = true; } }); // Return false if we didn't find the type if ( !found ){ return false; } } // Try to get the venue from the name if it's not a Mongo ID else if ( options.field === 'venue_id' && !(options.value.length == 24 && options.value.match(/[^0-9a-f]/)) ){ var found = false; angular.forEach( formScope.venues, function(venue, index){ if ( venue.title.trim() == options.value.trim() ){ options.value = venue._id; found = true; } }); // Return false if we didn't find the venue if ( !found ){ return false; } } formScope.$apply(function(){ formScope[options.field] = options.value; }); return this; } DMN.toggleInput = function(){ if (!arguments.length){ return false; } if ( !angular.isObject(arguments[0]) ){ arguments[0] = { input: arguments[0], visible: arguments[1] }; } var defaults = { formId: false } var options = angular.extend({}, defaults, arguments[0]); // Stop if no input specified if ( !options.input ){ return false; } // Get the form scope var formScope = DMN.getFormScope(options.formId); // Stop if no form scope if ( !formScope ){ return false; } formScope.$apply(function(){ formScope.hiddenInputs = formScope.hiddenInputs || {}; if ( typeof options.visible === 'undefined' ){ formScope.hiddenInputs[options.input] = !formScope.hiddenInputs[options.input]; } else { formScope.hiddenInputs[options.input] = !options.visible; } }); return this; } DMN.showInput = function(input){ return DMN.toggleInput.call(this, input, true); } DMN.hideInput = function(input){ return DMN.toggleInput.call(this, input, false); } DMN.addCustomData = function(key, value){ var defaults = { formId: false } var options = angular.extend({}, defaults, arguments[0]); // Get the form scope var formScope = DMN.getFormScope(options.formId); formScope.customData = formScope.customData || {}; formScope.customData[key] = value; return this; } "use strict";DMN.ready(function(){DMN.loadScript("https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js",DMN.loadSupportingScripts)}),DMN.loadSupportingScripts=function(){var e=DMN.partnersUrl+"/js/partner-ticket-widget-vendor.js";DMN.loadScript(e,DMN.init)},DMN.init=function(){var e,t;angular.forEach(DMN.formConfig,function(i,n){e||i.rendered||(e=n,t=i)}),DMN.formConfig[e].rendered=!0;var i=document.getElementById("dmn-form-"+e),n=(angular.element(i),angular.module("DMNPartnerTicketWidget",["ui.bootstrap"])),a=i.parentNode,o=angular.element(a)[0],s=t.format;o.className+="list"==s?" dmn-ticket-widget-parent dmn-ticket-widget-list-parent":" dmn-ticket-widget-parent "+o.className,n.controller("MainCtrl",["$scope","$modal","Events",function(e,i,n){e.formDetails={},e.formField={},e.stage=t.stage||"dates",e.initialStage=t.stage||"dates",e.showContent=t.showContent||!1,e.title=t.title||"Buy a ticket",e.logo=t.logo||"//static.designmynight.com/images/designmynight-grey.png",e.isLoading={events:!1,dates:!1,tickets:!1,quantity:!1};var a=t.eventIds||[];e.setIsLoading=function(t,i){e.isLoading[t]=i||!1},e.setIsLoading("events",!0),n.findEvents(a).then(function(t){e.formDetails.events=t,e.canSelectEvent=!0,e.formField.event=t[0]._id,e.setIsLoading("events",!1)}),e.updateEvents=function(t){t&&(e.setIsLoading("dates",!0),n.findDates(e.formField.event).then(function(t){e.formField.date="",e.formDetails.dates=t,e.multiDate=Object.keys(t).length>1?!0:!1,e.canSelectDate=!0;angular.forEach(t,function(e){e.on_sale||(e.extra=" (Not on sale)")}),angular.isObject(t)&&angular.forEach(t,function(t,i){t.on_sale&&!e.formField.date&&(e.formField.date=i)}),e.setIsLoading("dates",!1)}))},e.updateDates=function(t){e.canSelectTicket=!1,e.formField.ticket="",e.isAllSoldOut=!1,t&&(e.setIsLoading("tickets",!0),console.log("$scope.formField.date",e.formField.date),n.findTickets(e.formField.event,e.formField.date).then(function(t){e.formDetails.tickets=t;var i=0;if(t&&t.length>0){angular.forEach(t,function(t){console.log("ticket",t.on_sale),t.on_sale&&!t.is_sold_out?e.canSelectTicket=!0:t.is_sold_out?(t.extra=" (Sold out)",t.on_sale=!1,i++):(t.extra=" (Not on sale)",i++),"false"===t.on_sale&&(t.on_sale=!1,t.extra=" (Not on sale)",i++),t.displayVAT=!1,angular.forEach(e.formDetails.events,function(i){i._id===e.formField.event&&(t.displayVAT=i.display_vat||!1,t.hideSoldOutTickets=i.hide_sold_out_tickets||!1)}),t.displayVAT&&(t.price_exc_vat=t.price/1.2),t.displayPrice=t.displayVAT?"(£"+t.price_exc_vat.toFixed(2)+" | £"+t.price+" incl. VAT)":"(£"+t.price.toFixed(2)+")"}),i===t.length&&(e.isAllSoldOut=!0);for(var n=0;n